<template>
	<view class="personmessage-contain">
		<view class="top-title-view">
			<!-- 	<view class="mine qrCode" @click="qrCodeLogin">
				扫码登录
				<image class="qr-image" src="@/static/login/qr.png" mode="heightFix"></image>
			</view> -->
			<view class="mine">
				我的
			</view>
			<view class="mine operate">
				<picker mode=selector @change="selectOperate" range-key="name" :value="providerNo" :range="operatorList"
					class="picker">
					{{ operateName || '' }}
				</picker>
				<!-- <image src="@/static/index-message/switch2.png" mode="" class="img"></image> -->
			</view>
			<view class="top-title-view-shan">
				<view class="title-view-center">
					<view class="title-img">
						<image v-if="!personmes.avatar" class="title-image"
							src="@/static/socialized-service/specialist-consultation/user-module/person-messageuser/photo.png"
							mode="widthFix"></image>
						<image v-if="personmes.avatar" class="title-image" :src="personmes.avatar" mode=""></image>
					</view>
				</view>
			</view>
		</view>

		<view class="content-view" :style="{height:setcollapseheight() + 'px'}">
			<view class="title-name">
				<view class="name">
					{{ personmes.nickName }} ({{organizationObj&&organizationObj.name}})
				</view>
				<view class="type" v-if="operateName">
					入驻运营方: {{ operateName }}
				</view>
				<!--  -->
				<picker v-if="organizationList&&organizationList.length >1" mode=selector @change="selectOrganization"
					range-key="name" :value="organizationNo" :range="organizationList" class="picker organization-btn">
					切换主体
					<!-- <image src="@/static/index-message/switch2.png" mode="" class="img"></image> -->
				</picker>
			</view>

			<view class="btns">
				<!-- <div class="btn" @click="goServerApplication()">申请服务方</div>
				<div class="btn" @click="goMechanistApplication()">申请农机手</div>
				<div class="btn" @click="goAnchorApplication">申请为主播</div>
				<div class="btn" @click="goExpertApplication">申请为专家</div> -->
			</view>
			<view class="content-view-item" @click="toEdit()">
				<image class="content-view-item-img" src="@/static/person-mes/jbxx.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					基本信息
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view>
			<view class="content-view-item" @click="$refs.alertDialog.open()">
				<image class="content-view-item-img" src="@/static/person-mes/xgmm.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					修改密码
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view>
			<view  v-if='!personmes.registerType'  class="content-view-item" @click="toBindingSubject">
				<image class="content-view-item-img" src="@/static/person-mes/bdzt.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					绑定主体
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view>


			<view class="content-view-item" @click="dialogToggle">
				<image class="content-view-item-img" src="@/static/person-mes/zxzh.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					注销
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view>
			<view class="content-view-item" @click="dialogServiceOnlineToggle">
				<image class="content-view-item-img" src="@/static/person-mes/fwsxx.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					服务上下线
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view>
			<!-- 	<view class="content-view-item">
				<image class="content-view-item-img" src="@/static/person-mes/wenzhen.png" mode="widthFix"></image>
				<view class="content-view-item-value" @click="goMyPost">
					<view v-if="!isExpertFlag">
						我的问诊
					</view>
					<view v-else>
						我的诊断
					</view>
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view> -->



			<!-- <view class="content-view-item" @click="goFarmService">
				<image class="content-view-item-img" src="@/static/person-mes/machinery.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					<view>
						我的农事服务订单
					</view>
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view> -->

			<!-- <view class="content-view-item" @click="toEditPassword">
				<image class="content-view-item-img" src="@/static/person-mes/edit.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					修改密码
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view> -->
			<!-- 
			<view class="content-view-item">
				<image class="content-view-item-img" src="@/static/person-mes/bianzu.png" mode="widthFix"></image>
				<view class="content-view-item-value-left">
					所属主体：
				</view>
				<view class="content-view-item-value-right">
					<view>-</view>
					<view>-</view>
				</view>
			</view> -->


			<view v-if="partyNo" class="content-view-item" @click="toConsulted">
				<image class="content-view-item-img" src="@/static/person-mes/prod.png" mode="widthFix"></image>
				<view class="content-view-item-value">
					咨询反馈
				</view>
				<uni-icons type="arrowright" color="#000"></uni-icons>
			</view>

			<view class="content-view-item">
				<image class="content-view-item-img" src="@/static/person-mes/jbxx.png" mode="widthFix"></image>
				<view class="content-view-item-value-left">
					版本号：
				</view>
				<view class="content-view-item-value-right">
					v{{ version }}
				</view>
			</view>

		</view>

		<view class="but-view">
			<!-- <button @click="toEdit()" class="but1-sty">修改个人资料</button> -->
			<button @click="newloginoutmet()" class="but1-sty">退出登录</button>
		</view>
		<uni-popup ref="inputServiceOnlineDialog" type="dialog">
			<uni-popup-dialog cancelText="关闭" confirmText="" title="服务上下线" :before-close="true"
				@confirm="dialogServiceOnlineConfirm" @close="() =>{$refs.inputServiceOnlineDialog.close();}">
				<view class="" style="color: red;width: 100%;">
					注意：服务下线后将无法接到新的订单
				</view>
				<view class="switch-btn">
					<u-switch size="60" :activeValue='1' :inactiveValue='0' inactive-color="#dd524d"
						v-model="serviceOnlineValue"></u-switch>
					<view class="switch-btn-text" :class="{inactive:!serviceOnlineValue}"
						@click="serviceOnlineValue = serviceOnlineValue?0:1">
						{{ serviceOnlineValue ? '服务上线中' : '服务下线中' }}
					</view>
				</view>

			</uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog cancelText="关闭" confirmText="确认注销" title="注销" value="" placeholder="请输入'确认注销', 注销将删除账号"
				:before-close="true" @confirm="dialogInputConfirm"
				@close="() =>{$refs.inputDialog.close();$set(formData, 'contactNumber', '')}">
				<uni-forms ref="form" :rules="rules" :model="formData">
					<uni-forms-item class="password-item" label="手机号：" name="phone">
						<view class="">
							{{ formData.phone || formData.phoneNumber }}
						</view>
					</uni-forms-item>
					<uni-forms-item class="password-item" label="" name="contactNumber">
						<uni-easyinput type="text" :input-border="false" v-model="formData.contactNumber"
							placeholder="请输入验证码" />
						<button style="font-size: 26rpx;
									padding: 6rpx 12rpx;
									background: #e6dce0;
									color: #0288ed;
									border-radius: 10rpx;
									margin-left: 12rpx;
									width: 160rpx;
									text-align: center;" :disabled="disabled" @click="getCode">{{ captchaText }}</button>
					</uni-forms-item>
				</uni-forms>
			</uni-popup-dialog>
		</uni-popup>
		<!-- 修改密码 -->
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog :type="'info'" cancelText="取消" confirmText="确认" :title="'修改密码'" :before-close="true"
				@confirm="dialogConfirm" @close="() =>{$refs.alertDialog.close()}">
				<view slot="default" class="report-progress">
					<uni-forms ref="form" :rules="rules" :model="formData">
						<uni-forms-item class="password-item" label="原密码：" name="password">
							<uni-easyinput type="password" :input-border="false" v-model="formData.password"
								placeholder="请输入原密码" />
						</uni-forms-item>
						<uni-forms-item class="password-item" label="新密码：" name="newPassword">
							<uni-easyinput type="password" :input-border="false" v-model="formData.newPassword"
								placeholder="请输入新密码" />
						</uni-forms-item>
						<uni-forms-item class="password-item" label="确认密码：" name="newPasswords">
							<uni-easyinput type="password" :input-border="false" v-model="formData.newPasswords"
								placeholder="请输入确认密码" />
						</uni-forms-item>
					</uni-forms>
				</view>
			</uni-popup-dialog>
		</uni-popup>
		<bottomBar></bottomBar>
	</view>
</template>

<script>
	import bottomBar from "@/components/socialized-bottomtabar/home-bottomtabar"
	import agriculturalApi from '@/api/socialized-servce/agricultural-information/index.js'
	import loginApi from '@/api/socialized-servce/login/index.js'
	import {
		addressList
	} from '@/subPage1/plugins/address.js'
	export default {
		components: {
			bottomBar,
		},
		data() {
			let validateFunctionPass = (rule, value, data, callback) => {
				if (value !== this.formData.newPassword) {
					callback('两次输入密码不一致')
				} else {
					callback()
				}
			}
			
			let validateFunctionPass1 = (rule, value, data, callback) => {
				if (value === this.formData.password) {
					callback('原密码不能和新密码一致')
				} else {
					callback()
				}
			}
			let validateFunctionCodeNum = (rule, value, data, callback) => {
				// if (value !== this.formData.newPassword) {
				// 	callback('两次输入密码不一致')
				// }
				return loginApi.queryVerificatCode({
					"codeNum": value,
					"phoneNum": this.formData && this.formData.phone || this
						.formData && this.formData
						.phoneNumber
				}).then(res => {
					// console.log(res)
					if (res.data === false) {
						callback('验证码错误')
					} else {
						callback()
					}
				})
				// return true
			}
			return {
				version: uni.getSystemInfoSync().appVersion || '',
				partyNo: uni.getStorageSync('partyNo'),
				personmes: {},
				userTypeName: [],
				isMachinery: false,
				isAnchor: false,
				organizationFlag: false,
				isExpertFlag: false,
				operateName: '',
				operatorList: [],
				providerNo: '',
				organizationNo: '',
				userTypeNameList: [],
				formData: {},
				organizationObj: {},
				organizationList: {},
				time: 0,
				captchaText: '获取验证码',
				disabled: false,
				serviceOnlineValue: 0,
				rules: {
					phone: {
						rules: [{
							required: true,
							errorMessage: '请刷新',
						}]
					},
					contactNumber: {
						rules: [{
								required: true,
								errorMessage: '请输入验证码',
							},
							{
								required: true,
								validateFunction: validateFunctionCodeNum,
							}
						]
					},
					password: {
						rules: [{
							required: true,
							errorMessage: '请输入原密码',
						}]
					},
					newPassword: {
						rules: [{
							required: true,
							errorMessage: '请输入新密码',
						}, {
							// \1{2}) 后面 (?!.*(012|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210))，并且不能连续出现3个大小连续或相同的数字
							pattern: /^(?=.*\d)(?!.*(\d)\1{2})(?=.*[a-zA-Z]).{6,20}$/,
							errorMessage: '至少包含字母、数字，6-20位',
						},
						{
							required: true,
							validateFunction: validateFunctionPass1
						}
						]
					},
					newPasswords: {
						rules: [{
							required: true,
							errorMessage: '请再次输入新密码',
						}, {
							required: true,
							validateFunction: validateFunctionPass

						}]
					},
				}
			}
		},
		onShow() {
			uni.hideTabBar()
			this.providerNo = uni.getStorageSync('providerNo')
			this.getpersonmessage()
			// this.userTypeName = JSON.parse(uni.getStorageSync('userTypeNameList'))
			this.isExpertFlag = uni.getStorageSync('isExpertFlag')
		},
		mounted() {
			let providerNo = uni.getStorageSync('providerNo')
			this.isMachinery = uni.getStorageSync('isMachinery').includes(providerNo)
			this.isAnchor = uni.getStorageSync('isAnchor').includes(providerNo)
			this.switchOrganization()
			// this.getOperatorList()
			
			// #ifdef APP-PLUS
			this.versionCheck()
			// #endif
		},
		methods: {
			versionCheck() {
				let that = this;
				plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
					that.version = wgtinfo.version //客户端版本号
				})
			},
			dialogServiceOnlineToggle() {
				this.$refs.inputServiceOnlineDialog.open();
			},
			dialogToggle() {
				this.$refs.inputDialog.open();
			},
			getCode() {
				// this.$refs.form.validateField('contactNumber', (valid) => {
				//   if (!valid) {
				this.$set(this.formData, 'contactNumber', '')
				loginApi.querySendCode({
					phoneNum: this.formData.phone || this.formData.phoneNumber
				}).then(res => {
					if (res.code === 200) {
						uni.showToast({
							title: '发送成功',
							icon: 'loading'
						});
						this.$set(this.formData, 'codeNum', res.data.codeNum)
						// 倒计时时间 60秒
						this.time = 60
						this.timer = setInterval(() => {
							this.time--
							this.captchaText = this.time + 's'
							this.disabled = true
							if (this.time === 0) {
								this.timer && clearInterval(this.timer)
								this.disabled = false
								this.captchaText = '获取验证码'
							}
						}, 1000)
					} else {
						// this.$message.error(res.msg)
					}
				})
				//   }
				// })
			},
			dialogConfirm() {
				this.$refs.form.validate().then(async res => {
					let params = {
						// ...this.formData,
						// organizationNo: uni.getStorageSync('organizationNo')
						// organizationNo: uni.getStorageSync('organizationNo'),
						username: uni.getStorageSync('username-sa') || this.formData.userName,
						password: this.formData.password,
						newPassword: this.formData.newPassword
					};
					await loginApi.updatePassword(params).then(
						res => {
							if (res.code == 200) {
								uni.showToast({
									title: "修改成功"
								})
								this.$refs.alertDialog.close()
							} else {
								uni.showToast({
									title: res.msg || '修改失败',
									icon: 'none'
								});
							}
							// console.log(res)
						});
				}).catch(err => {
					console.log('表单错误信息：', err);
				})
			},
			dialogInputConfirm(val) {
				this.$refs.form.validate().then(async res => {
					let username = uni.getStorageSync('username');
					// let url = `socialized/system/user/deactivate`;
					loginApi.deactivate({
						phoneNum: this.formData.phone,
						codeNum: this.formData.codeNum || this.formData.contactNumber
					}).then(res => {
						if (res.code === 200) {
							this.$store.commit({
								type: 'refreshdata'
							});
							uni.showToast({
								title: '注销成功',
								icon: 'loading'
							});
							uni.clearStorageSync();
							uni.reLaunch({
								url: '/pages/login/login'
							})
						} else {
							uni.showToast({
								title: '注销失败，请联系管理员',
								icon: 'none'
							});
						}
					});
				}).catch(err => {
					console.log('表单错误信息：', err);
				})
			},
			// 服务上下线
			dialogServiceOnlineConfirm() {
				loginApi.onlineAndOffline({
					organizationNo: uni.getStorageSync('organizationNo') || 'jkadihgedadad',
					status: this.serviceOnlineValue
				}).then(res => {
					if (res.code === 200) {
						uni.showToast({
							title: '修改成功',
							icon: 'loading'
						});
						this.$refs.inputServiceOnlineDialog.close();
						this.switchOrganization()
					} else {
						uni.showToast({
							title: '修改失败',
							icon: 'none'
						});
					}
				});
			},
			// 普通用户获取运营方(需要调整参数)
			async getOperatorList() {
				let params = {
					organizationNo: uni.getStorageSync('organizationNo')
				}
				let res = await loginApi.queryOperator(params)
				if (res.code === 200) {
					this.operatorList = res.data
					// uni.setStorageSync('providerNo', this.operatorList[0] && this.operatorList[0].providerNo)
					if (!uni.getStorageSync('providerNo')) {
						uni.setStorageSync('providerNo', this.operatorList[0] && this.operatorList[0].providerNo)
					}
					this.providerNo = uni.getStorageSync('providerNo')
					if (res.data.length > 0) {
						if (this.providerNo) {
							this.operateName = this.operatorList.filter(el => el.providerNo === this
								.providerNo)[0].name
						}
					}

				}
			},
			// 服务提供方系统切换服务提供方(需要调整参数)
			async switchOrganization() {
				let params = {
					userNo: uni.getStorageSync('userNo')
				}
				let res = await loginApi.switchOrganization(params)
				if (res.code === 200) {
					if (res.data.length === 1) {
						this.organizationList = res.data
						this.organizationObj = res.data[0]
						uni.setStorageSync('organizationNo', this.organizationObj.organizationNo)
						uni.setStorageSync('partyNo', this.organizationObj.organizationNo)
						uni.setStorageSync('manageUserNo', this.organizationObj.manageUserNo)
						this.serviceOnlineValue = this.organizationObj.status
						this.partyNo = this.organizationObj.organizationNo
						if (uni.getStorageSync('userNo') === this.organizationObj.manageUserNo) {
							this.manageUserStatus = true
						} else {
							this.manageUserStatus = false
						}
						this.getOperatorList()
					} else {
						this.organizationList = res.data
						let index = this.organizationList.findIndex(item => item.organizationNo === uni.getStorageSync(
							'organizationNo'))
						if (index !== -1) {
							this.organizationObj = this.organizationList[index]
							uni.setStorageSync('organizationNo', this.organizationObj.organizationNo)
							uni.setStorageSync('partyNo', this.organizationObj.organizationNo)
							uni.setStorageSync('manageUserNo', this.organizationObj.manageUserNo)
							this.serviceOnlineValue = this.organizationObj.status
							this.partyNo = this.organizationObj.organizationNo
							if (uni.getStorageSync('userNo') === this.organizationObj.manageUserNo) {
								this.manageUserStatus = true
							} else {
								this.manageUserStatus = false
							}
						} else {
							this.organizationObj = this.organizationList[0]
							this.partyNo = this.organizationObj.organizationNo
							uni.setStorageSync('manageUserNo', this.organizationObj.manageUserNo)
							this.serviceOnlineValue = this.organizationObj.status
							if (uni.getStorageSync('userNo') === this.organizationObj.manageUserNo) {
								this.manageUserStatus = true
							} else {
								this.manageUserStatus = false
							}
						}
						this.getOperatorList()
					}

				}
			},


			setAddress(data) {
				let pName = addressList.filter(el => el.provinceId == data.provinceId)[0].name
				let cName = addressList.filter(el => el.provinceId == data.provinceId)[0].city.filter(el1 => el1.cityId ==
					data.cityId)[0].name
				let aName = addressList.filter(el => el.provinceId == data.provinceId)[0].city.filter(el1 => el1.cityId ==
					data.cityId)[0].area.filter(el2 => el2.areaId == data.areaId)[0].name
				uni.setStorageSync('serviceProviderAddress', `${pName}${cName}${aName}${data.address}`)
			},
			// 切换运营方
			selectOperate(e) {
				this.userTypeNameList = []
				this.operateName = this.operatorList[e.detail.value || 0].name
				let providerNo = this.operatorList[e.detail.value || 0].providerNo
				uni.setStorageSync('providerNo', providerNo)
				uni.setStorageSync('providerName', this.operateName)
				// this.setAddress(this.operatorList[e.detail.value || 0])
				// this.isMachinery = uni.getStorageSync('isMachinery').includes(providerNo)
				// this.isAnchor = uni.getStorageSync('isAnchor').includes(providerNo)
				// this.isExpert = uni.getStorageSync('isExpert').includes(providerNo)
				// uni.setStorageSync('isExpertFlag', this.isExpert)
				// if (this.isMachinery) {
				// 	this.userTypeNameList.push('农机手')
				// }
				// if (this.isExpert) {
				// 	this.userTypeNameList.push('专家')
				// }
				// if (this.isAnchor) {
				// 	this.userTypeNameList.push('主播')
				// }
				// uni.setStorageSync('userTypeNameList', JSON.stringify(this.userTypeNameList))
				this.userTypeName = this.userTypeNameList
				this.$socketApi.initSocket()
			},
			// 切换服务方
			selectOrganization(e) {
				this.organizationObj = {
					...this.organizationList[e.detail.value || 0]
				}
				let organizationNo = this.organizationList[e.detail.value || 0].organizationNo
				uni.setStorageSync('organizationNo', organizationNo)
				uni.setStorageSync('partyNo', organizationNo)
				uni.setStorageSync('manageUserNo', this.memberObj&&this.memberObj.manageUserNo)
				uni.setStorageSync('organizationName', this.organizationObj && this.organizationObj.name)
				this.getOperatorList()
			},
			//修改密码
			toEditPassword() {
				uni.navigateTo({
					url: `/pages/find-password/find-password?edit=1&username=${this.personmes.userName}`,

				})
			},
			getout() {

				const url = '/pages/login/login'
				// uni.clearStorageSync()
				uni.showToast({
					title: '退出账号',
					icon: 'loading'
				})
				uni.reLaunch({
					url: url
				})
			},
			toHome() {
				let url = '/pages/socialized-service/selection-system/selection-system'
				this.$togo(url)
			},
			// 获取当前用户信息
			getpersonmessage() {
				loginApi.queryByUserNo({
					userNo: uni.getStorageSync('userNo')
				}).then(res => {
					this.personmes = res.data || {}
					this.formData = res.data || {}
					this.organizationFlag = this.personmes.organizationFlag
					uni.setStorageSync('username-sa', res.data.userName)
					uni.setStorageSync('avatar', this.personmes.avatar)
				})
			},
			// 修改个人信息
			toEdit() {
				let param = this.personmes
				let url = '/pages/socialized-service/person-message/person-editmes'
				this.$togo(url, param)
			},
			// 咨询反馈
			toConsulted() {
				let url = '/pages/socialized-service/person-message/chat/chat'
				this.$togo(url)
			},
			// 入驻管理
			toEntry() {
				let url = '/pages/socialized-service/person-message/entry-management/entry-management'
				this.$togo(url, {
					userNo: this.personmes && this.personmes.userNo
				})
			},
			// 主体绑定
			toBindingSubject() {
				let url = '/pages/socialized-service/person-message/binding-subject/binding-subject'
				this.$togo(url, {
					userNo: this.personmes && this.personmes.userNo
				})
			},
			// 登出账号
			newloginoutmet() {
				this.$store.commit({
					type: 'refreshdata'
				})
				let cid = uni.getStorageSync('cid')
				let toUrlindex = uni.getStorageSync('toUrlindex')
				uni.clearStorageSync()
				uni.setStorageSync('toUrlindex', toUrlindex)
				uni.setStorageSync('cid', cid)
				uni.$emit('loginOut')
				uni.showToast({
					title: '退出账号',
					icon: 'loading'
				})
				uni.reLaunch({
					url: '/pages/login/login'
				})
			},
			//  设置内容高度
			setcollapseheight() {
				let topheightone = uni.upx2px(270)
				let newheight = this.customBar + topheightone
				let winHeight = 0
				uni.getSystemInfo({
					success: function(res) {
						winHeight = res.windowHeight
					}
				});
				let oldHeight = uni.upx2px(260)
				winHeight = parseInt(winHeight) - newheight - oldHeight
				// #ifndef H5
				winHeight = winHeight - 10
				// #endif
				return winHeight
			},
			goMyPost() {
				if (!this.isExpertFlag) {
					uni.redirectTo({
						url: `/subPage1/socialized-service/specialist-consultation/user-module/my-consultation/my-consultation?type=user`
					})
				} else {
					uni.redirectTo({
						url: `/subPage1/socialized-service/specialist-consultation/expert-module/my-diagnosis/my-diagnosis?type=expert`
					})
				}
			},
			// 农机手
			goMechanistApplication() {
				if (this.isMachinery) {
					uni.redirectTo({
						url: '/subPage1/socialized-service/farm-service/person-message/under-review/under-review'
					})
					return
				}
				uni.redirectTo({
					url: '/subPage1/socialized-service/farm-service/person-message/mechanist-application/mechanist-application'
				})
			},
			// 服务方
			goServerApplication() {
				if (this.organizationFlag) {
					uni.redirectTo({
						url: '/subPage1/socialized-service/farm-service/person-message/under-review/under-review'
					})
					return
				}
				uni.redirectTo({
					url: '/subPage1/socialized-service/farm-service/person-message/server-application/server-application'
				})
			},
			// 专家
			goExpertApplication() {
				if (this.isExpertFlag) {
					uni.redirectTo({
						url: '/subPage1/socialized-service/farm-service/person-message/under-review/under-review'
					})
					return
				}
				uni.redirectTo({
					url: '/subPage1/socialized-service/farm-service/person-message/expert-application/index'
				})
			},
			// 主播
			goAnchorApplication() {
				if (this.isAnchor) {
					uni.redirectTo({
						url: '/subPage1/socialized-service/farm-service/person-message/under-review/under-review'
					})
					return
				}
				uni.redirectTo({
					url: '/subPage1/socialized-service/farm-service/person-message/anchor-application/index'
				})
			},
			goFarmService() {
				// 目前只是判断是否是农机手
				let url = ''
				// if(this.isMachinery || this.isAnchor) {
				// 	url = `/subPage1/socialized-service/farm-service/mechanist/my-order/my-order?personmessage=personmessage`
				// } else {
				url = `/subPage1/socialized-service/farm-service/normalUser/myOrder/myOrder?personmessage=personmessage`
				// }
				uni.redirectTo({
					url: url
				})
			},
			qrCodeLogin() {
				uni.scanCode({
					success: (res) => {
						// 扫描成功
						this.loginWithQRCode(res.result);
					},
					fail: () => {
						// 扫描失败
						uni.showToast({
							title: '扫描失败',
							icon: 'none'
						});
					}
				});
			},
			loginWithQRCode(res) {
				let data = res && JSON.parse(res)
				loginApi.authLoginCode({
					code: data.content
				}).then(res => {
					uni.showToast({
						title: '登录中...',
						icon: 'none',
						duration: 2000
					});
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/style/variables.scss";

	::v-deep {
		.uni-dialog-content {
			flex-wrap: wrap;
			text-align: center;
		}
	}

	.switch-btn {
		display: flex;
		align-items: center;
		padding: 20rpx 10rpx;

		.switch-btn-text {
			padding-left: 10rpx;
			font-size: 32rpx;

			&.inactive {
				color: #dd524d;
			}
		}
	}

	.personmessage-contain {
		width: 100%;
		// font-size: 14px;
		// line-height: 24px;

		.top-title-view {
			width: 100%;
			height: 490rpx;
			// background: linear-gradient(180deg, #0480FB 0%, #0480FB 100%);
			background: url(@/static/login/bg.png);
			background-repeat: no-repeat;
			background-size: cover;
			padding-top: 20rpx;
			position: relative;

			.mine {
				position: absolute;
				top: 100rpx;
				left: 50%;
				transform: translateX(-50%);
				font-size: 32rpx;
				font-weight: 500;
				color: #FFFFFF;
			}

			.qrCode {
				left: auto;
				right: -40rpx;
				font-size: 30rpx;

				.qr-image {
					height: 38rpx;
					vertical-align: bottom;
					margin-left: 8rpx;
				}
			}

			.operate {
				right: 10rpx;
				left: auto;
				transform: translateX(0);
				display: flex;
				justify-content: center;
				align-items: center;
				// // #ifdef APP-PLUS
				// top: 45rpx;
				// // #endif
				background: #FFFFFF;
				border-radius: 30rpx 30rpx 30rpx 30rpx;
				padding: 10rpx 30rpx;
				box-sizing: border-box;
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 400;
				font-size: 24rpx;
				color: #1A8DFF;
				line-height: 32rpx;
				text-align: center;
				max-width: 300rpx;
				overflow: auto;

				.img {
					width: 19rpx;
					height: 24rpx;
					margin-right: 10rpx;
				}

				&::after {
					content: '';
					width: 0;
					height: 0;
					border-top: 10rpx solid #1A8DFF;
					border-right: 10rpx solid transparent;
					border-left: 10rpx solid transparent;
				}
			}

			.btn {
				position: absolute;
				top: 50%;
				z-index: 9999;
			}

			.top-title-view-shan {
				width: 100%;
				height: 300rpx;
				background-size: 100% 300rpx;
				background-repeat: no-repeat;
				background-position: center;
			}

			.title-view-center {
				width: 100%;
				margin-top: 100rpx;
				height: 180rpx;
				display: flex;
				flex-wrap: wrap;
				justify-content: center;

				.title-name {
					height: 50rpx;
					// background-color: #00363D;
					width: 100%;
					text-align: center;
					height: 50rpx;
					line-height: 50rpx;
					color: #000;
					font-size: 17px;
					font-weight: 600;
				}

				.title-img {
					z-index: 100;
					width: 166rpx;
					height: 166rpx;
					background: #FFFFFF;
					margin-top: 30rpx;
					border-radius: 50%;
					opacity: 1;
					display: flex;
					justify-content: center;
					align-content: center;
					flex-wrap: wrap;
					position: relative;

					.title-image {
						width: 148rpx;
						height: 148rpx;
						// background: #424A60;
						opacity: 1;
						border-radius: 50%;
					}
				}
			}

			.gif-wave {


				position: absolute;
				width: 100%;
				bottom: -2rpx;
				left: 0;
				z-index: 99;
				mix-blend-mode: screen;
				height: 200rpx;
				width: 100%;

				// background-color: #000000;
				.gif-wave-img {
					height: 200rpx;
					width: 100%;
				}
			}

			.consultation-times {
				position: absolute;
				bottom: -60rpx;
				left: 50%;
				transform: translateX(-50%);
				font-size: 24rpx;
				font-weight: 400;
				color: #0480FB;
			}
		}

		.tabbar {
			width: 100%;
			height: 454rpx;
			// background: linear-gradient(315deg, #0480FB 0%, #57DED9 100%);
			color: #393939;
			display: flex;
			justify-content: center;
			// align-content: center;
			flex-wrap: wrap;
			position: relative;

			.tabbar-bgc {
				width: 750rpx;
				height: 272rpx;
				background: linear-gradient(360deg, #F5F6FA 0%, rgba(245, 246, 250, 0) 100%);
				position: absolute;
				bottom: 0rpx;
			}

			.home {
				position: fixed;
				top: 90rpx;
				right: 40rpx;
				width: 60rpx;
			}
		}

		.personmessage-contain-view {
			width: 100%;
			margin-top: -240rpx;

			.personmessage-contain-view-lineone {
				width: 100%;
				display: flex;
				flex-direction: column;
				align-items: center;

				.user-name {
					color: #fff;
					z-index: 1;
					font-size: 32rpx;
					margin-bottom: 60rpx;
					letter-spacing: 6rpx;
				}

				.contain-view-lineone-img {
					width: 160rpx;
					height: 160rpx;
				}
			}

		}

		.content-view {
			margin: 30rpx;
			box-sizing: border-box;
			position: absolute;
			z-index: 5;
			width: calc(100% - 60rpx);
			max-height: calc(100% - 500rpx);
			overflow: hidden auto;
			background-color: #fff;
			top: 200rpx;
			border-radius: 50rpx;
			padding: 0 20rpx;

			.title-name {
				padding: 90rpx 0 10rpx;
				display: flex;
				font-size: 32rpx;
				justify-content: center;
				flex-direction: column;
				.name {
					color: #272727;
					font-weight: 500;
					width: 100%;
					text-align: center;
					margin-bottom: 20rpx;
				}

				.type {
					color: #747474;
					font-size: 26rpx;
					text-align: center;
				}
			}

			.btns {
				display: flex;
				height: 46rpx;
				margin-top: 20rpx;
				margin-bottom: 20rpx;

				.btn {
					display: flex;
					align-items: center;
					justify-content: center;
					flex: 1;
					margin-left: 4rpx;
					background: #FFFFFF;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
					opacity: 1;
					border: 2rpx solid #2165FF;
					font-weight: 400;
					color: #2165FF;
					font-size: 28rpx;

					&:first-child {
						margin-left: 0;
					}
				}
			}

			.content-view-item {
				width: calc(100% - 40rpx);
				height: 60rpx;
				// margin-top: 30rpx;
				padding: 20rpx;
				display: flex;
				flex-direction: row;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: space-between;
				background-color: #fff;
				// box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.05);
				border-radius: 20rpx;
				font-size: 32rpx;
				border-bottom: 1px solid #eee;

				&:first-child {
					margin-top: 0;
				}

				.content-view-item-img {
					width: 40rpx;
					height: 40rpx;
					margin-right: 8rpx;
				}

				.content-view-item-value {
					width: 520rpx;
					height: 60rpx;
					line-height: 60rpx;
					font-size: 28rpx;
				}

				.content-view-item-value-left {
					font-size: 28rpx;
					width: 120rpx;
				}

				.content-view-item-value-right {
					font-size: 28rpx;
					width: 430rpx;
					// text-align: right;
				}
			}
		}

		.but-view {
			margin-top: 20rpx;
			text-align: center;
			position: fixed;
			bottom: 160rpx;
			left: 50%;
			transform: translateX(-50%);
			width: 100%;
			bottom: calc(160rpx + constant(safe-area-inset-bottom)); //180rpx
			/* 兼容 iOS < 11.2 */
			bottom: calc(160rpx + env(safe-area-inset-bottom));

			/* 兼容 iOS >= 11.2 */
			.but1-sty {
				// display: inline-block;
				width: 240rpx;
				height: 60rpx;
				letter-spacing: 4rpx;
				color: #fff;
				font-size: 24rpx;
				background-image: linear-gradient(135deg, #2469fe, #86aafc);
				border-radius: 50rpx;

				&:first-child {
					margin-bottom: 20rpx;
					background-image: none;
					background-color: #fff;
					color: #9b895f;
					border: 1px solid #9b895f;
				}
			}

		}
	}

	.editpassword {
		position: absolute;
		right: -120rpx;
		top: 50%;
		transform: translateY(-50%);
		color: #fffdef;
	}

	.password-item {
		::v-deep {
			.uni-forms-item__label {
				white-space: nowrap;
			}

			.uni-forms-item__content {
				white-space: nowrap;
				display: flex;
				align-items: center;

			}
		}
	}

	.organization-btn {
		position: absolute;
		right: 20rpx;
		top: 0;
		color: #fff;
		padding: 10rpx 30rpx;
		background: linear-gradient(270deg, #88ACFF 0%, #2165FF 100%);
		box-shadow: 0rpx 0rpx 8rpx 2rpx rgba(0, 0, 0, 0.16);
		border-radius: 30rpx 30rpx 30rpx 30rpx;
		max-width: 200rpx;
		overflow: auto;
		display: flex;
		align-items: center;
		white-space: nowrap;

		.img {
			width: 20rpx;
			height: 20rpx;
		}

		&::after {
			content: '';
			width: 0;
			height: 0;
			border-top: 10rpx solid #fff;
			border-right: 10rpx solid transparent;
			border-left: 10rpx solid transparent;
		}

	}
</style>